/*
  ! 如果没有天赋，那就一直重复
  ! Created: 2024/06/04 09:29:16
*/
#include <bits/stdc++.h>
using namespace std;

#define x first
#define y second
// #define int long long
#define mp(x, y) make_pair(x, y)
#define eb(...) emplace_back(__VA_ARGS__)
#define fro(i, x, y) for (int i = (x); i <= (y); i++)
#define pre(i, x, y) for (int i = (x); i >= (y); i--)
inline void JYFILE19();

using i64 = long long;
using PII = pair<int, int>;

bool ST;
const int N = 310;
const int mod = 998244353;

int n, m, ans, h[N], dp[N][N][N];

inline void ckmin(int &x, int y) {
  x = min(x, y);
}

signed main() {
  JYFILE19();
  cin >> n;
  fro(i, 1, n) cin >> h[i];
  memset(dp, 0x3f, sizeof dp);
  dp[0][0][0] = 0, ans = 1e9;
  fro(i, 0, n - 1) fro(l1, 0, i) {
    int r1 = n - i + l1 + 1;
    fro(l2, 0, i) {
      int r2 = n - i + l2 + 1, v = dp[i][l1][l2];
      ckmin(dp[i + 1][l1][l2], v + (h[r1 - 1] != r2 - 1));
      ckmin(dp[i + 1][l1][l2 + 1], v + (h[r1 - 1] != l2 + 1));
      ckmin(dp[i + 1][l1 + 1][l2], v + (h[l1 + 1] != r2 - 1));
      ckmin(dp[i + 1][l1 + 1][l2 + 1], v + (h[l1 + 1] != l2 + 1));
    }
  }
  fro(l1, 0, n) fro(l2, 0, n) ckmin(ans, dp[n][l1][l2]);
  cout << ans << "\n";
  return 0;
}

bool ED;
inline void JYFILE19() {
  freopen("build.in", "r", stdin);
  freopen("build.out", "w", stdout);
  srand(random_device{}());
  ios::sync_with_stdio(0), cin.tie(0);
  double MIB = fabs((&ED - &ST) / 1048576.), LIM = 512;
  cerr << "MEMORY: " << MIB << endl, assert(MIB <= LIM);
}